home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
BC_TI.ARJ
/
TI735.ASC
< prev
next >
Wrap
Text File
|
1992-02-25
|
2KB
|
67 lines
PRODUCT : Borland C++ NUMBER : 735
VERSION : 2.0
OS : DOS
DATE : February 25, 1992 PAGE : 1/1
TITLE : Determining Program Size
/**********************************************************************
The size of a program cannot be determined statically because the
the stack and near heap are sized dynamically at run time. The
load size specified in the EXE header is incorrect for this
reason. The only way to accurately determine the program image
size is to check it at run time.
This program will get the current size of the program image in
memory. This size will change dynamically as the program acquires
memory from and releases memory to DOS. This in formation is
stored in the Memory Control Block (MCB). The MCB begins one
paragraph (16 bytes) before the Program Segment Prefix (PSP).
The current program size is stored at offset 0x3 from the
beginning of the MCB. Offset 0x3 represents the size in
paragraphs therefore it must be multiplied by 16 to obtain the
size in bytes.
WRITTEN BY
Jerry Shockley 9/19/91
**********************************************************************/
#include <dos.h>
unsigned _stklen = 63000u; //This size can be changed to see the
size
// size change.
void main()
{
unsigned far *size;
size = MK_FP( _psp - 1, 0x03 );
printf("\nSize of program in memory = %l0u", (unsigned long)
(*size) * 16 );
}